package com.gxa.customer.security.security.handler;

import com.gxa.common.utils.MD5;
import org.springframework.security.crypto.password.PasswordEncoder;
import org.springframework.stereotype.Component;

@Component
public class DefaultPasswordEncoder implements PasswordEncoder {


    //自定义密码加密方式,进行MD5加密
    @Override
    public String encode(CharSequence charSequence) {
        return MD5.encrypt(charSequence.toString());
    }
    //自定义密码解密方式,进行密码比对
    @Override
    public boolean matches(CharSequence charSequence, String encodedPassword) {
        //进行客户端密码和与数据库密码进行比较
        //System.out.println("进行密码比对"+MD5.encrypt(charSequence.toString()));
        return encodedPassword.equals(MD5.encrypt(charSequence.toString()));
    }
}
